-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Re-bundle server app in adapter-node #1648
Conversation
I'm not sure whether this is something that we'd expect esbuild to be able to do, but currently with this PR if you The CJS helper that esbuild is using and injecting is: var __require = (x) => {
if (typeof require !== "undefined")
return require(x);
throw new Error('Dynamic require of "' + x + '" is not supported');
}; (and then later on the bundle has I'm not sure what can be done to make this work other than to have a |
esbuild doesn't seem to transform require()s of Node builtins into imports, so define a global.require for them.
I've just push a |
Will this also fix #1428 ? |
It should. That looks like a duplicate of #1257. |
Fixes #1257. This makes adapter-node run the server-side app through esbuild as part of the build process, treating anything in (prod)
dependencies
as external, and bundling everything else. This means that, for example,@sveltejs/kit
will no longer need to be installed when deploying the production app - and any other dependencies that the app adds asdevDependencies
will also be bundled in. This means that, in production, you should be able to copy over yourpackage.json
andbuild/
, runnpm install --production
, and runnode build
- which is what you'd expect to be able to do.These changes seem to behave as expected on the project I have at work (which adds a number of dependencies, some of which should be bundled on the server and some of which should not) - but I'd still appreciate some more eyes on this PR.
Before submitting the PR, please make sure you do the following
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpx changeset
and following the prompts